<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>部门管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/demo.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/zTreeStyle.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .alerts{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
       .alerts .alerts_content{background:#fff;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 500px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .wait{ display:none;background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 250px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
       .alerts .alerts_content h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 99%;margin-bottom:30px;background: #d0e0e0}
       .alerts .alerts_content .alerts_form{
        width:100%;
       }
         .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
       .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;border:4px solid #ccc;box-sizing: border-box;overflow: hidden;/* margin 负值为宽高的一半 */}
       .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 100%;background: #d0e0e0}
       .alert_addNewZone .alert_addNewZone_content .alert_addNewZone_form{
        width:100%;
       }
       .alert_addNewZone_tree .alert_addNewZone_content_tree .alert_addNewZone_form_tree{
        height: 280px;
        width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
       }
       .alerts .alerts_content .alerts_form form{width: 100%;}
       .alerts .alerts_content .alerts_form form div{margin-bottom:30px;width: 100%;text-align: center;}
       .alerts .alerts_content .alerts_form form div label{display:inline-block;width: 130px;text-align: right;}
       .alerts .alerts_content .alerts_form form div:nth-of-type(1) input{margin-right: 28px;}
        .mtp{margin-top:3px;}
        .no-padding{padding: 0;}
        #gopage{color:blue;cursor: pointer;}
        #firstpage{cursor: pointer;}


           .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgb(255,255,255,0.7);z-index: 200}
       .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 350px;margin: -150px 0 0 -250px;border:4px solid #ccc;box-sizing:border-box;overflow: hidden;/* margin 负值为宽高的一半 */}
       .wait,.waits{background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
       .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 100%;background: #d0e0e0}
    </style>
</head>

<body class="white-bg" style="color:#333;padding:3px;">
          <div class="page-heade">
       <h2 class="title_color text-center">部门管理</h2>
    </div>
        <div class="col-md-12 mtp no-padding">
			<div class="col-md-3">
				<div>
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
			<div class="col-md-9 no-padding">
				<table class="table" style="width: 100%;">
					<tbody>
						<tr>
							<td colspan="5">
								<button class="btn btn-sm btn-primary addDepart">添加部门</button>
	            				<button class="btn btn-sm btn-primary" id="drbm">导入部门</button>
	            				<button class="btn btn-sm btn-primary" id="fzr">导入负责人</button>
	            				<button class="btn btn-sm btn-primary" onclick="huishou()">回收站</button>
							</td>
						</tr>
						<form action="#" method="get" id="form_check">
						<tr>
							<td>部门名称</td>
							<td><input type="text" id="de_name" name="de_name" value="{$de_name}" class="form-control" /></td>
							<td>部门类型</td>
							<td>
								<select id="check_type" name="check_type" class="select form-control">
									<option value='1'>本部门及其下属</option>
									<option value='2' {if condition='$check_type=="2"'}selected{/if}>本部门</option>
									<option value='3' {if condition='$check_type=="3"'}selected{/if}>下属部门</option>
								</select>
							</td>
							<td>
								<input type="hidden" value='{$list}' name="list"/>
								<input type="submit" value="查询" class="btn btn-sm btn-info"/>
	            				<input type="button" class="btn btn-sm btn-info" id="reset" value="查询条件清空"/>
	            				<input type="button" class="btn btn-sm btn-info" id="daochu" value="导出Excel"/>
							</td>
						</tr>
						</form>
					</tbody>
				</table>
				{if condition="$sum neq 0"}
				<table class="table table-striped table-bordered table-hover bud_hei text-center" style="width: 100%;">
					<thead>
						<tr class='info'>
							<td style="width:5%;">序号</td>
							<td style="width:15%;">部门名称</td>
							<td style="width:15%;">部门第一负责人</td>
							<td style="width:15%;">上级部门</td>
							<td style="width:35%;">说明</td>
							<td style="width:15%;">操作</td>
						</tr>
						
					</thead>
					<tbody>
						{volist name="depart_arr" id="vo"}
							<tr ind="{$vo.index}">
								<td>{$i}</td>
								<td>{$vo.de_name}</td>
								<td emid="{$vo.em_id}">{$vo.em_name}</td>
								<td pid={$vo.parent_id}>{$vo.pde_name}</td>
								<td>{$vo.remark}</td>
								<td issale="{$vo.is_sale}"><a href="javascript:;" class='xgbm' deid="{$vo.id}">修改</a>
                                &nbsp;<a onclick="shanchu({$vo.id})">删除</a></td>
							</tr>
						{/volist}
						
					</tbody>

				</table>
				 <h5 class="text-center" id="pagesc" style="font-size: 16px;font-weight: 500">
					总共有{$sum}条记录，第<span id="currentPage">{$page}</span>/<span id="maxPage">{$maxpage}</span>页,当前页<input id="page" type="text"  style="width: 40px" value="{$page}"/><span id="gopage">Go</span>&nbsp;
					<a href="javascript:;" id="preBtn" style="font-size: 16px;font-weight: bold;">上一页</a>
					<a href="javascript:;" id="nextBtn" style="font-size: 16px;font-weight: bold;">下一页</a>
					&nbsp;<span id="fistpage" style="font-size: 16px;font-weight: bold;cursor: pointer;">首页</span>&nbsp;&nbsp;
					每页显示
					<select id="pagesize">
						<option value='5' {if condition="$list eq 5"}selected{/if}>5条</option>
						<option value='10'{if condition="$list eq 10"}selected{/if}>10条</option>
					</select>
				</h5>
				{else/}
				<h3>对不起没有查询到符合条件的信息</h3>
				{/if}
			</div>
        </div>
    <!--新增部门弹框-->
	<div class="alert_addDepart alerts">
        <div class="alerts_content animated fadeInUp">
            <h3><span id="istj">添加部门</span><a style="float: right;margin-right: 10px;font-size: 20px" id="del_this">&times;</a></h3>
            <div  class="alerts_form">
                <form id="newdepart">
                   	<table class="table table-bordered">
							<input type="hidden" value="0" id="isupdate"/>
							<tr>
								<td class="text-right font-bold" >部门名称<span style="color: red">*</span>:</td>
								<td><input type="text" style="width:80%"  id="new_de_name" class="form-control" /></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >第一负责人:</td>
								<td>
                                    <input type="hidden" name="principal" id="principal" value='0' class="form-control" />
                                    <span id="prin_kg"></span>
                                <a href="javascript:;" class="fuzeren">选择</a></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >显示次序<span style="color: red">*</span>:</td>
								<td><input type="text" name='index' id="index" style="width:80%" class="form-control" /></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >上级部门:</td>
								<td><span id="par_kg"></span>
									<input type="hidden" value='0' name="parent_id" id="parent_id" class="form-control" />
								<a href="javascript:;" class="bumen">选择</a></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >是否销售部门:</td>
								<td>
									<label for="is_sale0"><input type='radio' name='is_sale' id="is_sale0" value='0' checked/>否</label>
									<label for="is_sale1"><input type='radio' name='is_sale' id="is_sale1" value='1'/>是</label>
								</td>
							</tr>
							
							<tr>
								<td class="text-right font-bold" >说明:</td>
								<td>
									<textarea id="remark" style="width:80%;height:100px;resize: none;" class="form-control"></textarea>
								</td>
							</tr>
                   	</table>
                   	<div class="row text-center">

                        <h5 class="text-center" style="color:red;" id="wrong_msg">&nbsp;</h5>
                         
                         
                        
						<input type="button" value="保存" id="bc" class="btn btn-primary"/>
                       
                   	</div>
                </form>
            </div>
        </div>
        <!--新增部门弹框-->
        <!--树状人员弹框-->
		<div class="alert_addNewZone_tree">
	        <div class="alert_addNewZone_content_tree animated fadeInUp">
	            <h3><span id="txtree"></span><a style="float: right;margin-right: 10px;font-size: 20px" id="del_this1">&times;</a></h3>
	            <div  class="alert_addNewZone_form_tree" id="fenqu_fzr">
	              <ul id="tree_em" class="ztree"></ul>
	               <div class="quedingbtn text-center" style="position: absolute;right: 0;bottom: 10px;"><button class="btn btn-primary" id="qd">确定</button></div>
	            </div>
	            
	        </div>
	        <div class="wait">
   				<div class="ibox ">
                    <div class="ibox-title">
                        <h5>正在获取员数据.....</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="spiner-example">
                            <div class="sk-spinner sk-spinner-chasing-dots">
                                <div class="sk-dot1"></div>
                                <div class="sk-dot2"></div>
                            </div>
                        </div>
                    </div>
                </div>

	        </div>
  		 </div>
        <!--树状人员弹框-->

    </div>
 
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
     <!-- Peity -->
    <script src="__STATIC__/layout/js/plugins/peity/jquery.peity.min.js"></script>

    <!-- jqGrid -->
    <script src="__STATIC__/layout/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
    <script src="__STATIC__/layout/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>

    <!-- 自定义js -->
    <script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
    
    <!-- ztree -->
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.excheck.js"></script>
    <!--统计代码，可删除-->
   <script>
   $("#daochu").click(function(){
        window.open("{:url('bumendaochu')}")
   })
   function huishou(){
    location.href="{:url('huishou')}"
   }
   function shanchu(id){
    $.post("{:url('shanchu')}",{id:id},function(re){
        var data=JSON.parse(re);
        if(data["state"]==2){
             swal({
                            title: "错误",
                            text:  data["msg"],
                            type: "warning"
                            });
        }else{
             swal({
                  title: "提示",
                  text: "您是否确定要删除该部门",
                  type: "warning",
                  showCancelButton: true,
                  confirmButtonColor: "#DD6B55",
                  confirmButtonText: "确定",
                  cancelButtonText: "取消"
                  
                },
                function(){
                    $.post("{:url('shanchucz')}",{id:id},function(re){
                        if(re==1){
                            alert("操作已成功")
                            location.href="{:url('manage')}"
                        }else{
                            alert("系统繁忙，请稍后")
                        }
                    })
                });
        }
    })
   }
   $("#fzr").click(function(){
    location.href="{:url('fuzeren')}"
   })
   $("#drbm").click(function(){
    location.href="{:url('import')}"
   })
   //员工树配置
   var setting_em = {
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: emOnCheck
            }
        };
        //员工树选择
        function emOnCheck(event, treeId, treeNode) {
            if(treeNode.checked==true){
               
                $("#principal").val(treeNode.eid);
                $("#prin_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxem();' style='cursor:pointer;font-size:16px'>x</span></span>");
            }else{
                $("#principal").val(0);
                $("#prin_kg").html("");
            }
        };
        //取消员工
       function qxem(){
             $("#principal").val(0);
                $("#prin_kg").html("");
        }
        //上级部门配置
         var setting_de = {
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: deOnCheck
            }
        };
        //部门树选择
        function deOnCheck(event, treeId, treeNode) {
            if(treeNode.checked==true){
               
                $("#parent_id").val(treeNode.id);
                $("#par_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxde();' style='cursor:pointer;font-size:16px'>x</span></span>");
            }else{
               $("#par_kg").html("");
                $("#parent_id").val(0);
            }
        };
         //取消部门
       function qxde(){
             $("#par_kg").html("");
            $("#parent_id").val(0);
        }
        function disabledNode(e) {
            var zTree = $.fn.zTree.getZTreeObj("tree_em"),
            disabled = e.data.disabled,
            nodes = zTree.getSelectedNodes();
            if (nodes.length == 0) {
                alert("请先选择一个节点");
            }

            for (var i=0, l=nodes.length; i<l; i++) {
                zTree.setChkDisabled(nodes[i], disabled);
            }
        }

    $(document).ready(function(){
       //点击进入部门数据加载
       $(".bumen").click(function(){
            $(".alert_addNewZone_tree").show();
            $("#txtree").html("部门列表");
            $("#fenqu_fzr").hide();
                $(".wait").show();

           $.post("{:url('Departments/getbm')}",{did:$("#isupdate").val(),pid:$("#parent_id").val()},function(re){
                var data_de=JSON.parse(re);
                
                $("#fenqu_fzr").show();
                $(".wait").hide();
                $.fn.zTree.init($("#tree_em"), setting_de, data_de);
                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
           })
       })
        //点击选择进入员工树数据加载
    	$(".fuzeren").click(function(){

    		$(".alert_addNewZone_tree").show();
            $("#txtree").html("员工列表");
    		$("#fenqu_fzr").hide();
                $(".wait").show();

           $.post("{:url('Departments/getem')}",function(re){
                var data_em=JSON.parse(re);
                
                $("#fenqu_fzr").show();
                $(".wait").hide();
                $.fn.zTree.init($("#tree_em"), setting_em, data_em);
                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
           })
    		
    	})
        //关闭人员树状图
    	$("#del_this1").click(function(){
             
    		$(".alert_addNewZone_tree").hide();
    	})
        //关闭人员树状图
        $("#qd").click(function(){
            
            $(".alert_addNewZone_tree").hide();
        })
        //部门名规则//字母数字下划线长度1-20
        var regex_de_name=/^[a-zA-Z0-9_\u4e00-\u9fa5]{1,20}$/;

    	//提交验证
    	$("#bc").click(function(){
            //单元格
            //isupdate更新或创建
            //new_de_name部门名称
            //principal负责人
            //index次序
            //parent_id
            //is_sale
            //remark
           
            if($("#new_de_name").val().replace(/(^\s*)|(\s*$)/g, "")!=""){
                if(regex_de_name.test($("#new_de_name").val())){
                    if($("#index").val()!=""){
                        $.ajax({
                           type: "POST",
                           url: "{:url('Departments/editorcreate')}",
                           async: false,
                           data: "isupdate="+$("#isupdate").val()+"&dename="+$("#new_de_name").val()+"&principal="+$("#principal").val()+"&index="+$("#index").val()+"&pid="+$("#parent_id").val()+"&is_sale="+$("input[name=is_sale]:checked").val()+"&remark="+$("#remark").val(),
                           success: function(msg){
                            //alert(msg);
                             if(msg==1){
                                     swal({
                                            title: "完成",
                                            text: "您的操作已成功",
                                            type: "success"
                                        },function(){
                                            location.href="{:url('Departments/manage')}";
                                        });
                                }else if(msg==2){
                                    $("#wrong_msg").html("请填写次序");
                                }else if(msg==3){
                                    $("#wrong_msg").html("部门名称不能为空");
                                }else if(msg==4){
                                     $("#wrong_msg").html("系统繁忙，请稍后");
                                }else if(msg==5){
                                     $("#wrong_msg").html("部门已存在");
                                }else if(msg==6){
                                     $("#wrong_msg").html("不能设定本部门为上级部门");
                                }else{
                                    $("#wrong_msg").html(msg);
                                }

                           }
                        });
                        
                    }else{
                        $("#wrong_msg").html("请填写次序");
                    }
                }else{
                    $("#wrong_msg").html("部门名称包含非法字符（只能是中文，数字，字母，下划线）");
                 }
            }else{
                 $("#wrong_msg").html("部门名称不能为空");
            }
            
            
        });

	
    	//清空查询
    	$("#reset").click(function(){
    		
    		$("#de_name").val("");
    		$("#check_type").val(1);
    		document.getElementById("form_check").submit();

    	
    	})
    	//储存搜索内容
    	var de_name=$("#de_name").val();
    	var check_type=$("#check_type").val();
    	var search_str='{:url("Departments/manage")}?check_type='+check_type;
    	if(de_name!=""){
    		search_str+="&de_name="+de_name;
    	}
    	//切换页码长度
    	$("#pagesize").change(function(){
    		search_str+="&list="+$(this).val();
    		location.href=search_str;
    	})
    	$("#page").keyup(function(){

    		if(isNaN(parseInt($(this).val()))){
				$(this).val(1);
    		}else{
				$(this).val(parseInt($(this).val()));
    		}
    		
    	})
        $("#index").keyup(function(){

            if(isNaN(parseInt($(this).val()))){
                $(this).val("");
            }else{
                $(this).val(parseInt($(this).val()));
            }
            
        })
    	$("#gopage").click(function(){
    		search_str+="&list="+$("#pagesize").val();
    		search_str+="&page="+$("#page").val();
    		location.href=search_str;
    	})
        $("#fistpage").click(function(){
            search_str+="&list="+$("#pagesize").val();
            search_str+="&page=1";
            location.href=search_str;

        })
        
        //修改部门弹框
        $(".xgbm").click(function(){
            var departid=$(this).attr("deid");
             $("#isupdate").val(departid);
            $(".alert_addDepart").show();
            $("#istj").html("部门修改");
            //填写信息
            $("#new_de_name").val($(this).parent().prev().prev().prev().prev().html());
            if($(this).parent().prev().prev().prev().html()!=""){
                $("#principal").val($(this).parent().prev().prev().prev().attr("emid"));
                 $("#prin_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+$(this).parent().prev().prev().prev().html()+"&nbsp;&nbsp;<span onclick='qxem();' style='cursor:pointer;font-size:16px;'>x</span></span>");
            }
            $("#index").val($(this).parent().parent().attr("ind"));

            if($(this).parent().prev().prev().html()!=""){
                $("#parent_id").val($(this).parent().prev().prev().attr("pid"));
                $("#par_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+$(this).parent().prev().prev().html()+"&nbsp;&nbsp;<span onclick='qxde();' style='cursor:pointer;font-size:16px;'>x</span></span>");
            }
            $("#remark").val($(this).parent().prev().html());
            if($(this).parent().attr("issale")=="1"){
                 $("input[name=is_sale]").eq(1).prop("checked",true);
            }
        })
    	//添加部门弹框
        $(".addDepart").click(function(){
             $("#isupdate").val(0);
            $(".alert_addDepart").show();
            $("#istj").html("添加部门")
        });
        $("#del_this").click(function(){
            $(".alert_addDepart").hide();
            $(".alert_addDepart input[type=text]").val("");
            $("input[name=is_sale]").eq(0).prop("checked",true);
            $(".alert_addDepart textarea").val("");
            $("#wrong_msg").val("&nbsp;");
            reset_form();
           
        });
        

    })
    	
    //清空选择
    function reset_form(){
            // 清空负责人
           qxem();
            //清空上级部门
            qxde();

    }
    $("#preBtn").click(function(){
    		var check_type=$("#check_type").val();
    		var search_str='{:url("Departments/manage")}?check_type='+check_type;
    		var prePageNum=Number($("#currentPage").text())
					console.log(prePageNum);
					if(prePageNum>1){
							search_str+="&list="+$("#pagesize").val();
    						search_str+="&page="+(Number($("#page").val()-1));
    						location.href=search_str;
					}else{
						alert("已经是第一页！")
					}
    })
	$("#nextBtn").click(function(){
			var check_type=$("#check_type").val();
    		var search_str='{:url("Departments/manage")}?check_type='+check_type;
		var prePageNum=Number($("#currentPage").text())
					var nextPage = Number($("#maxPage").text())		
					console.log(prePageNum,nextPage);
					if(nextPage>prePageNum){
								search_str+="&list="+$("#pagesize").val();
    							search_str+="&page="+( Number($("#page").val())+Number(1));
    						location.href=search_str;
					}else{
						alert("已经是最后一页！")
					}
})

   </script>
<script type="text/javascript">
        <!--
       var setting = {
            check: {
                enable: false,
               
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
				onClick: zTreeOnClick
			}
        };
     
        var zn='{$alldepart}';
        var zNodes =JSON.parse(zn);
        
        var code;       
        function setCheck() {
            var type = $("#level").attr("checked")? "level":"all";
            setting.check.radioType = type;
            showCode('setting.check.radioType = "' + type + '";');
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            
        }
        function showCode(str) {
            if (!code) code = $("#code");
            code.empty();
            code.append("<li>"+str+"</li>");
        }
        
        $(document).ready(function(){
            setCheck();         
            $("#level").bind("change", setCheck);
            $("#all").bind("change", setCheck);
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
			treeObj.expandAll(true)
        });
        function zTreeOnClick(event, treeId, treeNode) {
    		$("#de_name").val(treeNode.name);
    		document.getElementById("form_check").submit();
		};
    </script>
</body>

</html>
